package com.yc.blog.springmvc.jsp.ctr;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 跳转jsp页面
 */
@Controller
public class DemoController1 {

	/**
	 * 跳转页面<p>
	 * 方式：返回ModelAndView<p>
	 * @return
	 */
	@RequestMapping("/c1-1")
	public ModelAndView c1() {
		System.out.println("--------c1-1---------");
		
		ModelAndView mv = new ModelAndView();
		
		mv.setViewName("/jsp/page2.jsp");//指定页面
		
		mv.addObject("para1", "aaaaa");//绑定参数1
		mv.addObject("para2", "bbbbb");//绑定参数2
		
		return mv;
	}
	
	/**
	 * 仅跳转页面<p>
	 * 方式：直接返回字符串
	 * @return
	 */
	@RequestMapping("/c1-2")
	public String c2() {
		System.out.println("--------c1-2---------");
		
		return "/jsp/page1.jsp";
	}
	
	
//	@RequestMapping("/c1-3")
//	public String c3(ModelAndView mv) {
//		System.out.println("--------c1-3---------");
//		
//		mv.addObject("para1", "aaaaa");//绑定参数1
//		mv.addObject("para2", "bbbbb");//绑定参数2
//		
//		return "/jsp/page2.jsp";
//	}

}
